<template>
  <view class="All_welfareList" :style="{ height: pageHeight + 'px' }">
    <view class="welfareList" v-for="(item, index) in userList" :key="index" @click="tabUser(item.driver_id)">
     <!-- <u-icon name="checkmark-circle-fill" color="#2979ff" size="38" v-if="active == item.driver_id"></u-icon>
      <u-icon name="checkmark-circle" color="#999" size="38" v-else></u-icon> -->
       <uni-icons type="checkbox-filled" :color="active == item.driver_id?'#2979ff':'#999'"  size="28"></uni-icons>
      <view class="right_welfare">
        <view class="user_welfare">
          <text>{{ item.driver_name }}</text>
          <text>{{ item.driver_mobile }}</text>
        </view>
        <view class="type_welfare">
          <view>
            <text>充值金额:</text>
            <text>{{ item.recharge_money }}元</text>
          </view>
          <view>
            <text>加注量:</text>
            <text>{{ item.filling_count }}公斤</text>
          </view>
          <view>
            <text>加注金额:</text>
            <text>{{ item.filling_money }}元</text>
          </view>
          <view>
            <text>订单:</text>
            <text>{{ item.filling_nums }}单</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { onMounted, PropType, Ref, ref } from 'vue';

defineProps({
  userList: {
    type: Array as PropType<Array<any>>,
    default: () => [],
  },
});

// static
const pageHeight = ref('');
const active: Ref<number> = ref(null);

const emit = defineEmits(['tabUser']);

onMounted(() => {
  //获取可视区域的高度
  uni.getSystemInfo({
    success(res) {
      pageHeight.value = (res.windowHeight - 80).toString();
    },
  });
});

function tabUser(num: number) {
  active.value = num;
  emit('tabUser', num);
}
</script>

<style lang="less">
.All_welfareList {
  width: 100%;
  overflow: auto;
}
.welfareList {
  width: 95%;
  margin: 2.5%;
  background: #ffffff;
  border-radius: 5px;
  padding: 20rpx;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .right_welfare {
    width: 91%;
    .user_welfare {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin-bottom: 30rpx;
      text:nth-of-type(1) {
        margin-right: 20rpx;
      }
      text {
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #333333;
      }
    }
    .type_welfare {
      width: 100%;
      view {
        display: flex;
        align-items: center;
        justify-content: space-between;
        line-height: 50rpx;
      }
      text {
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #333333;
        margin-right: 15rpx;
      }
    }
  }
}
</style>
